-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build regex from JSON Schema in Rust #15
Conversation
This looks great, thanks! |
ab04e5b
to
15d9e19
Compare
b19cc7f
to
54a7aaa
Compare
FYI: I just rebased this to account for the changes in |
Status update: all the test for the |
All tests pass 🙌 I'll clean up the code, remove todos and unwraps and then we can proceed for review. |
Additional questions for reviewers. The original python implementation exposed the def to_regex(
resolver: Resolver, instance: dict, whitespace_pattern: Optional[str] = None
): But as far as I can tell it's only used in tests and only consumed by the Similarly I left function |
It can be a rather useful means of debugging (e.g. in an issue), so it's probably worth exposing at the Python level, but we can skip that for now if you want. |
Okay that's good to know. For me we can keep it, no worries 👍 |
347e191
to
c448997
Compare
d496984
to
efa5c85
Compare
Had to rebase again for upstream fixes/changes. Also, I'll provide a review shortly! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Thank you 🙌 |
Resolves #12
In relation to the conversation in #12 I opened this PR to share the code that I wrote a while ago. Essentially this was intended as a 1-to-1 Rust port of the
build_regex_from_schema
function.Runningpytest tests/fsm/test_json_schema.py
I get: 18 failed, 45 passed, this excludes the tests forto_regex
since that function isn't fully implemented on the rust side.build_regex_from_schema
andto_regex
to rust.unwrap()
sNB!
The original python code has a
which I didn't find a good rust equivalent for. We can use the
jsonschema
crate like so:but it's slightly different and using for example "float" data types fail.
Additionally there's already the
let json_value: Value = serde_json::from_str(json)?;
which performs a form of validation on the incoming json.